<?php

class Model_Charge extends Model_Common {
	/* 订单号 */
	public function getOrderId($changeid,$orderinfo) {
		if($changeid) {
            $charge = DI()->notorm->charge_rules->select('*')->where('id=?', $changeid)->fetchOne();

            if (!$charge || $charge['coin'] != $orderinfo['coin'] || ($charge['money'] != $orderinfo['money'] && $charge['money'] != $orderinfo['money_ios'])) {
                return 1003;
            }

            $orderinfo['coin_give'] = $charge['give'];
        }

		$result= DI()->notorm->users_charge->insert($orderinfo);

		return $result;
	}

    /**
     * 会员卡充值规则
     */
	public function  monthCardList(){
        $charge=DI()->notorm->month_card->select('*')->order("orderno asc")->fetchAll();
        return $charge;
    }

    /* 订单号 */
    public function getCardOrderId($changeid,$orderinfo) {
        if($changeid) {
            $charge = DI()->notorm->month_card->select('*')->where('id=?', $changeid)->fetchOne();
            if (!$charge  || ($charge['coin'] != $orderinfo['money'] )) {
                return 1003;
            }
            $orderinfo['effect'] = "充值会员".$charge['name'];
            $orderinfo['month'] =$charge['month'];
        }

        $result= DI()->notorm->users_charge->insert($orderinfo);

        return $result;
    }

}
